package modellayer;

/**
 * This class makes discount by subtracting
 * a percentage from the price
 * @author (ucn-1semprojekt-dm78-gruppe1)
 *
 */
@SuppressWarnings("serial")
public class PercentDiscount implements DiscountSubTotal
{

	private String title;
	private double percent;
	
	/**
	 * @param title the description of this discount
	 * @param percent the percent to subtract from the price
	 */
	public PercentDiscount(String title, double percent)
	{
		this.title   = title;
		this.percent = percent;
	}
	
	/**
	 * @param normPrice the price to be discounted (cut off)
	 * @param amount the amount or pieces to be bought. Can be used
	 * to multiply the price if used in a container subclass.
	 * @return the discounted price 
	 */
	@Override
	public double subTotal(double normPrice, int amount)
	{
		// TODO Auto-generated method stub
		return normPrice - normPrice * percent/100;
	}
	
	/**
	 * @return a string representation of this object
	 */	
	public String toString()
	{
		return title + " : " + percent + "%";
	}

}
